﻿using System;

namespace TrinityEngine
{
    public static class Mathf
    {
        public const float PI = 3.14159265359f;

        public const float Deg2Rad = 0.0174532924f;

        public const float Rad2Deg = 57.29578f;

        public static float Lerp(float a, float b, float t)
        {
            return a + (b - a) * t;
        }

        public static float Clamp(float value, float min, float max)
        {
            if (value > max)
            {
                return max;
            }
            else if (value < min)
            {
                return min;
            }
            else
            {
                return value;
            }
        }

        public static float Clamp01(float value)
        {
            return Clamp(value, 0.0f, 1.0f);
        }

        public static float Round(float value)
        {
            return MathF.Round(value);
        }

        public static int RoundToInt(float value)
        {
            return (int)Round(value);
        }

        public static float Floor(float value)
        {
            return MathF.Floor(value);
        }

        public static int FloorToInt(float value)
        {
            return (int)Floor(value);
        }

        public static float Ceil(float value)
        {
            return MathF.Ceiling(value);
        }

        public static int CeilToInt(float value)
        {
            return (int)Ceil(value);
        }

        public static float Abs(float value)
        {
            return MathF.Abs(value);
        }

        public static float Sin(float rad)
        {
            return MathF.Sin(rad);
        }

        public static float Cos(float rad)
        {
            return MathF.Cos(rad);
        }

        public static float Tan(float rad)
        {
            return MathF.Tan(rad);
        }

        public static float Sqrt(float value)
        {
            return MathF.Sqrt(value);
        }

        public static float Pow(float f, float p)
        {
            return MathF.Pow(f, p);
        }

        public static float Log(float f, float p)
        {
            return MathF.Log(f, p);
        }

        public static float Max(float a, float b)
        {
            return MathF.Max(a, b);
        }

        public static float Min(float a, float b)
        {
            return MathF.Min(a, b);
        }

        public static int Max(int a, int b)
        {
            return Math.Max(a, b);
        }

        public static int Min(int a, int b)
        {
            return Math.Min(a, b);
        }

        public static float Repeat(float t, float length)
        {
            return t % length;
        }
    }
}
